﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using HoangPhap.EntityClasses;

namespace HoangPhap.Bussiness
{
    public class CharityProgram
    {
        public List<EntityClasses.CharityProgram> SelectAll()
        {
            var lst = new List<EntityClasses.CharityProgram>();
            var ct = new Data.HoangPhapDataContext().GetCharityProgramTranslationsSelectAllResults();
            if (ct.Rows.Count > 0)
            {
                lst.AddRange(from DataRow dt in ct.Rows
                             select new EntityClasses.CharityProgram
                             {

                                 RequestId = Convert.ToInt64(dt["	RequestId	"].ToString()),
                                 CreatedDate = Convert.ToDateTime(dt["	CreatedDate	"].ToString()),
                                 UpdatedDate = Convert.ToDateTime(dt["	UpdatedDate	"].ToString()),
                                 ExpectedStartDate = Convert.ToDateTime(dt["	ExpectedStartDate	"].ToString()),
                                 CharityProgramCost = Convert.ToDecimal(dt["	CharityProgramCost	"].ToString()),
                                 MinNeedMoney = Convert.ToDecimal(dt["	MinNeedMoney	"].ToString()),
                                 CharityProgramType = Convert.ToInt32(dt["	CharityProgramType	"].ToString()),
                                 Id = Convert.ToInt32(dt["	Id	"].ToString()),
                                 CertificateId = Convert.ToInt32(dt["	CertificateId	"].ToString()),
                                 OrganizationId = Convert.ToInt32(dt["	OrganizationId	"].ToString()),
                                 CharityProgramCategoryId = Convert.ToInt32(dt["	CharityProgramCategoryId	"].ToString()),
                                 Status = Convert.ToInt32(dt["	Status	"].ToString()),
                                 HoangphapUserId = Convert.ToInt32(dt["	HoangphapUserId	"].ToString()),
                                 EditorId = Convert.ToInt32(dt["	EditorId	"].ToString()),
                                 SystemSubAdminId = Convert.ToInt32(dt["	SystemSubAdminId	"].ToString()),
                                 ImageCover = dt["	ImageCover	"].ToString(),
                                 SmsSyntax = dt["	SmsSyntax	"].ToString(),
                                 Email = dt["	Email	"].ToString(),
                                 PhoneNumber = dt["	PhoneNumber	"].ToString(),
                                 ImageUrl = dt["	ImageUrl	"].ToString()

                             });
            }
            return lst;
        }

        public EntityClasses.CharityProgram SelectById(int id)
        {
            var lst = new EntityClasses.CharityProgram();
            var ct = new Data.HoangPhapDataContext().GetCharityProgramTranslationsSelectByIdResults(id);
            if (ct.Rows.Count <= 0) return lst;

            lst = new EntityClasses.CharityProgram
            {
                RequestId = Convert.ToInt64(ct.Rows[0]["	RequestId	"].ToString()),
                CreatedDate = Convert.ToDateTime(ct.Rows[0]["	CreatedDate	"].ToString()),
                UpdatedDate = Convert.ToDateTime(ct.Rows[0]["	UpdatedDate	"].ToString()),
                ExpectedStartDate = Convert.ToDateTime(ct.Rows[0]["	ExpectedStartDate	"].ToString()),
                CharityProgramCost = Convert.ToDecimal(ct.Rows[0]["	CharityProgramCost	"].ToString()),
                MinNeedMoney = Convert.ToDecimal(ct.Rows[0]["	MinNeedMoney	"].ToString()),
                CharityProgramType = Convert.ToInt32(ct.Rows[0]["	CharityProgramType	"].ToString()),
                Id = Convert.ToInt32(ct.Rows[0]["	Id	"].ToString()),
                CertificateId = Convert.ToInt32(ct.Rows[0]["	CertificateId	"].ToString()),
                OrganizationId = Convert.ToInt32(ct.Rows[0]["	OrganizationId	"].ToString()),
                CharityProgramCategoryId = Convert.ToInt32(ct.Rows[0]["	CharityProgramCategoryId	"].ToString()),
                Status = Convert.ToInt32(ct.Rows[0]["	Status	"].ToString()),
                HoangphapUserId = Convert.ToInt32(ct.Rows[0]["	HoangphapUserId	"].ToString()),
                EditorId = Convert.ToInt32(ct.Rows[0]["	EditorId	"].ToString()),
                SystemSubAdminId = Convert.ToInt32(ct.Rows[0]["	SystemSubAdminId	"].ToString()),
                ImageCover = ct.Rows[0]["	ImageCover	"].ToString(),
                SmsSyntax = ct.Rows[0]["	SmsSyntax	"].ToString(),
                Email = ct.Rows[0]["	Email	"].ToString(),
                PhoneNumber = ct.Rows[0]["	PhoneNumber	"].ToString(),
                ImageUrl = ct.Rows[0]["	ImageUrl	"].ToString(),

            };
            return lst;
        }

        public int DeleteById(int id)
        {
            return new Data.HoangPhapDataContext().CallCharityProgramTranslationsDeleteById(id);
        }

        public int DeleteDynamic(System.String whereCondition)
        {
            return new Data.HoangPhapDataContext().CallCharityProgramTranslationsDeleteDynamic(whereCondition);
        }

        //public int Insert(System.Int32 certificateId, System.Int32 organizationId, System.Int32 charityProgramCategoryId,
        //    System.String email, System.String phoneNumber, System.DateTime createdDate, System.DateTime updatedDate,
        //    System.String imageUrl, System.Int32 status, System.Int32 hoangphapUserId, System.Int32 editorId,
        //    System.Int32 systemSubAdminId, System.String imageCover, System.String smsSyntax, System.Int64 requestId,
        //    System.Int32 charityProgramType, System.Decimal charityProgramCost, System.Decimal minNeedMoney,
        //    System.DateTime expectedStartDate, ref System.Int32 id)
        //{
        //    return new Data.HoangPhapDataContext().CallCharityProgramTranslationsInsert(certificateId, organizationId, charityProgramCategoryId, email, phoneNumber, createdDate, updatedDate, imageUrl, status, hoangphapUserId, editorId, systemSubAdminId, imageCover, smsSyntax, requestId, charityProgramType, charityProgramCost, minNeedMoney, expectedStartDate, ref  id);
        //}

        //public int InsertUpdate(System.Int32 id, System.Int32 certificateId, System.Int32 organizationId, System.Int32 charityProgramCategoryId,
        //    System.String email, System.String phoneNumber, System.DateTime createdDate, System.DateTime updatedDate,
        //    System.String imageUrl, System.Int32 status, System.Int32 hoangphapUserId, System.Int32 editorId,
        //    System.Int32 systemSubAdminId, System.String imageCover, System.String smsSyntax, System.Int64 requestId,
        //    System.Int32 charityProgramType, System.Decimal charityProgramCost, System.Decimal minNeedMoney,
        //    System.DateTime expectedStartDate)
        //{
        //    return new Data.HoangPhapDataContext().CallCharityProgramTranslationsInsertUpdate(id, certificateId, organizationId, charityProgramCategoryId, email, phoneNumber, createdDate, updatedDate, imageUrl, status, hoangphapUserId, editorId, systemSubAdminId, imageCover, smsSyntax, requestId, charityProgramType, charityProgramCost, minNeedMoney, expectedStartDate);
        //}

        //public int Update(System.Int32 id, System.Int32 certificateId, System.Int32 organizationId, System.Int32 charityProgramCategoryId,
        //   System.String email, System.String phoneNumber, System.DateTime createdDate, System.DateTime updatedDate,
        //   System.String imageUrl, System.Int32 status, System.Int32 hoangphapUserId, System.Int32 editorId,
        //   System.Int32 systemSubAdminId, System.String imageCover, System.String smsSyntax, System.Int64 requestId,
        //   System.Int32 charityProgramType, System.Decimal charityProgramCost, System.Decimal minNeedMoney,
        //   System.DateTime expectedStartDate)
        //{
        //    return new Data.HoangPhapDataContext().CallCharityProgramTranslationsUpdate(id, certificateId, organizationId, charityProgramCategoryId, email, phoneNumber, createdDate, updatedDate, imageUrl, status, hoangphapUserId, editorId, systemSubAdminId, imageCover, smsSyntax, requestId, charityProgramType, charityProgramCost, minNeedMoney, expectedStartDate);
        //}
    }
}
